﻿using CoachingOrganizer.Toolkit.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoachingOrganizer.Logic.Models.Tools.MoneyCalculation
{
    public class MoneyCalculationModel : ToolModelBase
    {
        private readonly IncomesModel _incomes = new IncomesModel();
        private readonly SpentsModel _spents = new SpentsModel();
        private readonly ReportModel _report = new ReportModel();
        private DateTime _startDate = DateTime.Today;
        private DateTime _finishDate = DateTime.Today.AddDays(7.0);

        public IncomesModel Incomes
        {
            get { return _incomes; }
        }

        public SpentsModel Spents
        {
            get { return _spents; }
        }

        public ReportModel Report
        {
            get { return _report; }
        }

        public DateTime StartDate
        {
            get { return _startDate; }
            set { _startDate = value; }
        }

        public DateTime FinishDate
        {
            get { return _finishDate; }
            set { _finishDate = value; }
        }

        public MoneyCalculationModel()
        {

        }

        public async Task LoadMoneyFlowItemsAsync(System.Threading.CancellationToken cancelLoad)
        {
            await _incomes.LoadMoneyFlowItemsAsync(cancelLoad);
            await _spents.LoadMoneyFlowItemsAsync(cancelLoad);
        }

        public async Task<ActionResult> AddNewStableIncome(string name)
        {
            return await _incomes.AddNewStableMoneyFlowItem(name);
        }

        public async Task<ActionResult> AddNewOccasionalIncome(string name)
        {
            return await _incomes.AddNewOccasionalMoneyFlowItem(name);
        }

        public async Task<ActionResult> AddNewStableSpent(string name)
        {
            return await _spents.AddNewStableMoneyFlowItem(name);
        }

        public async Task<ActionResult> AddNewOccasionalSpent(string name)
        {
            return await _spents.AddNewOccasionalMoneyFlowItem(name);
        }
    }
}
